﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace WiMo.Games
{
    public struct Location
    {
        private int _x;
        private int _y;

        public Location(int x, int y)
        {
            _x = x;
            _y = y;
        }

        public Location(float x, float y)
        {
            _x = (int)x;
            _y = (int)y;
        }

        public Location(double x, double y)
        {
            _x = (int)x;
            _y = (int)y;
        }

        public int X { get { return _x; } set { _x = value; } }
        public int Y { get { return _y; } set { _y = value; } }

        public static Location Empty { get { return new Location(0, 0); } }

        public Location Add(Location location)
        {
            return new Location(X + location.X, Y + location.Y);
        }

        public Location Add(PointF point)
        {
            return new Location(X + (int)point.X, Y + (int)point.Y);
        }

        public Location Subtract(Location location)
        {
            return new Location(X - location.X, Y - location.Y);
        }

        public Location Subtract(PointF point)
        {
            return new Location(X - (int)point.X, Y - (int)point.Y);
        }

        public Location Clone()
        {
            return new Location(X, Y);
        }

        public override string ToString()
        {
            return string.Format("X={0} Y={1}", X, Y);
        }

        public static Location operator +(Location left, Location right)
        {
            return new Location(left.X + right.X, left.Y + right.Y);
        }
    }
}
